// $codepro.audit.disable
package edu.gatech.oad.cyberdoc.view;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JList;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.AbstractListModel;

import org.json.JSONObject;

import edu.gatech.oad.cyberdoc.presenter.Presenter;
import edu.gatech.oad.cyberdoc.view.menu.MenuButton;
import javax.swing.JTextField;

public class AdminAccountsPanel extends ApplicationPanel {
	private JTextField txtName;
	private JTextField txtPassword;
	private JTextField txtType;

	/**
	 * Create the panel.
	 */
	public AdminAccountsPanel() {
		setLayout(null);
		
		JLabel lblSelectAUser = new JLabel("Select a user from the list");
		lblSelectAUser.setBounds(10, 23, 280, 22);
		add(lblSelectAUser);
		
		JButton btnNewButton = new MenuButton("Create New User\r\n");
		btnNewButton.setBackground(SystemColor.activeCaption);
		btnNewButton.setBounds(156, 263, 191, 23);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Presenter.getInstance().createUser(txtName.getText(), txtType.getText(), txtPassword.getText());
			}
		});
		add(btnNewButton);
		
		JButton btnDeleteUser = new MenuButton("Delete User");
		btnDeleteUser.setBounds(156, 228, 191, 22);
		btnDeleteUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Presenter.getInstance().deleteUser(txtName.getText());
			}
		});
		add(btnDeleteUser);
		
		JButton btnSuspendAccount = new MenuButton("Suspend Account");
		btnSuspendAccount.setBounds(156, 297, 191, 22);
		btnSuspendAccount.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Presenter.getInstance().updateUser(txtName.getText(), "000");
			}
		});
		add(btnSuspendAccount);
		
		JButton btnUnsuspendAccount = new MenuButton("Unsuspend Account");
		btnUnsuspendAccount.setBounds(156, 330, 191, 22);
		btnUnsuspendAccount.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Presenter.getInstance().updateUser(txtName.getText(), txtPassword.getText());
			}
		});
		add(btnUnsuspendAccount);
		
		txtName = new JTextField();
		txtName.setText("Name");
		txtName.setBounds(156, 96, 191, 22);
		add(txtName);
		txtName.setColumns(10);
		
		txtPassword = new JTextField();
		txtPassword.setText("Password");
		txtPassword.setBounds(156, 162, 191, 22);
		add(txtPassword);
		txtPassword.setColumns(10);
		
		JButton btnChangeUserInformation = new MenuButton("Change User Password");
		btnChangeUserInformation.setBounds(156, 195, 191, 22);
		btnChangeUserInformation.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Presenter.getInstance().updateUser(txtName.getText(), txtPassword.getText());
			}
		});
		add(btnChangeUserInformation);
		
		txtType = new JTextField();
		txtType.setText("Type");
		txtType.setBounds(156, 129, 191, 22);
		add(txtType);
		txtType.setColumns(10);

	}

	@Override
	public void show(JSONObject response) {
		// TODO Auto-generated method stub
		
	}
}
